import QtQuick
import QtQuick.Controls
Column{
    anchors.centerIn: parent
    leftPadding: 50
    Row{
        //anchors.left: parent.left
        Button{
            text: "读温度"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log(inputTemperature.text)
                const resp  = test.getTemperature(inputTemperature.text)
                outTemperature.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,10);
                trueTemperature.text = parseInt(hexStr, 16)/10;
            }
        }

        Rectangle{
            width: 300; height: 30
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputTemperature
                text: "02 04 00 00 00 01 31 F9"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 30
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outTemperature
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 30
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueTemperature
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "读重量"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getWeight(inputWeight.text)
                outWeight.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,14);
                trueWeight.text = test.byteToFloat(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 30
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputWeight
                text: "0A 03 00 00 00 02 C5 70"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 30
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outWeight
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 30
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueWeight
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "读PH"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH.text)
                outPH.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH.text = test.byteToFloatFlip(hexStr);
                const h = resp.replace(/\s+/g, '').substring(38,46);
                console.log("h:", h);
                trueOrigin.text = test.byteToFloatFlip(h);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH
                text: "01 03 08 29 00 0A 16 65"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueOrigin
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "PH警告"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_Warning.text)
                outPH_Warning.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH_Warning.text = test.byteToFloatFlip(hexStr);
                const h = resp.replace(/\s+/g, '').substring(38,46);
                console.log("h:", h);
                trueOrigin_Warning.text = test.byteToFloatFlip(h);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_Warning
                text: "01 03 12 7F 00 08 70 AC"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_Warning
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_Warning
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueOrigin_Warning
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }


    Row{
        //anchors.left: parent.left
        Button{
            text: "PH错误"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_Error.text)
                outPH_Error.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH_Error.text = test.byteToFloatFlip(hexStr);
                const h = resp.replace(/\s+/g, '').substring(38,46);
                console.log("h:", h);
                trueOrigin_Error.text = test.byteToFloatFlip(h);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_Error
                text: "01 03 12 BF 00 08 70 90"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_Error
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_Error
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueOrigin_Error
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "PH温度"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_Temp.text)
                outPH_Temp.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH_Temp.text = test.byteToFloatFlip(hexStr);
                const h = resp.replace(/\s+/g, '').substring(38,46);
                console.log("h:", h);
                trueOrigin_Temp.text = test.byteToFloatFlip(h);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_Temp
                text: "01 03 09 69 00 0A 16 4D"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_Temp
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_Temp
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueOrigin_Temp
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "PHmV"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_mV.text)
                outPH_mV.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH_mV.text = test.byteToFloatFlip(hexStr);
                const h = resp.replace(/\s+/g, '').substring(38,46);
                console.log("h:", h);
                trueOrigin_mV.text = test.byteToFloatFlip(h);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_mV
                text: "01 03 0A 07 00 06 77 D1"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_mV
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_mV
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueOrigin_mV
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }


    Row{
        //anchors.left: parent.left
        Button{
            text: "PHTime"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_Time.text)
                outPH_Time.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,14);
                console.log(">>", hexStr);
                truePH_Time.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_Time
                text: "01 03 12 43 00 06 31 64"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_Time
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_Time
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueOrigin_Time
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "PHlogin"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_login.text)
                outPH_login.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,14);
                console.log(">>", hexStr);
                truePH_login.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_login
                text: "01 10 10 BF 00 04 08 00 30 00 00 79 CE 00 F4 97 E7"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_login
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_login
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }


    Row{
        //anchors.left: parent.left
        Button{
            text: "PHhml"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_hml.text)
                outPH_hml.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,14);
                console.log(">>", hexStr);
                truePH_hml.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_hml
                text: "01 10 25 01 00 02 04 00 01 00 00 C5 32"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_hml
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_hml
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }


    Row{
        //anchors.left: parent.left
        Button{
            text: "PH2point"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_2point.text)
                outPH_2point.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,14);
                console.log(">>", hexStr);
                truePH_2point.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_2point
                text: "01 10 14 29 00 02 04 51 EC 40 80 2F B4"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_2point
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_2point
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "PHstatus"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_status.text)
                outPH_status.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(6,14);
                console.log(">>", hexStr);
                truePH_status.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_status
                text: "01 03 14 25 00 06 D1 F3"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_status
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_status
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }


    Row{
        //anchors.left: parent.left
        Button{
            text: "PHParam"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_Param.text)
                outPH_Param.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH_Param.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_Param
                text: "01 03 15 47 00 06 71 D1"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_Param
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_Param
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        //anchors.left: parent.left
        Button{
            text: "PHquality"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                const resp  = test.getPH(inputPH_quality.text)
                outPH_quality.text = resp;

                const hexStr = resp.replace(/\s+/g, '').substring(14,22);
                console.log(">>", hexStr);
                truePH_quality.text = test.byteToFloatFlip(hexStr);
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputPH_quality
                text: "01 03 13 07 00 02 71 4E"
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outPH_quality
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: truePH_quality
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }




    Row{
        //anchors.left: parent.left
        Button{
            text: "test"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", text)
                test.name="10";
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: inputTest
                text: test !== null?test.name:""
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: outTest
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
                wrapMode: Text.WordWrap
            }
        }

        Rectangle{
            width: 300; height: 60
            border.color: "gray"
            color: 'linen'
            TextInput{
                id: trueTest
                leftPadding:2
                verticalAlignment: Text.AlignVCenter
                anchors.fill: parent
                focus: true
            }
        }
    }

    Row{
        spacing:10
        width: 100

        Repeater{
            id:repeater
            model: test?test.size:""
            delegate: TestBlueBox{
                width:100;height: 30
                text: index
            }
            onItemAdded: {
            }
        }
    }
    Row{
        Button{
            text: "测试Repater"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", repeater.model)
                //repeater.model=20
                test.size = 10

            }
        }

        Button{
            text: "测试Repater"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", repeater.model)
                //repeater.model=20
                test.size = undefined

            }
        }
    }
    Row{
        Button{
            text: "测试calibrationWeight"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button")
                //repeater.model=20
                test.calibrationgWeight()
            }
        }

        Button{
            text: "测试Repater"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", repeater.model)
                //repeater.model=20
                test.size = undefined

            }
        }

        Button{
            text: "CRC"
            width: 60
            anchors.verticalCenter: parent.verticalCenter

            onClicked:{
                console.log("click button", repeater.model)
                //repeater.model=20
                test.testCRC()

            }
        }
    }
}

